home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / var / lib / dpkg / info / libc6.postinst < prev    next >
Encoding:
Text File  |  2012-06-08  |  9.6 KB  |  306 lines

  1. #!/bin/sh
  2. set -e
  3. export LC_ALL=C
  4.  
  5. type=$1
  6. preversion=$2
  7.  
  8. package_name()
  9. {
  10.     echo libc6
  11. }
  12.  
  13. # element() is a helper function for file-rc:
  14. element() {
  15.     local element list IFS
  16.  
  17.     element="$1"
  18.  
  19.     [ "$2" = "in" ] && shift
  20.     list="$2"
  21.     [ "$list" = "-" ] && return 1
  22.     [ "$list" = "*" ] && return 0
  23.  
  24.     IFS=","
  25.     set -- $list
  26.     case $element in
  27.     "$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
  28.         return 0
  29.     esac
  30.     return 1
  31. }
  32.  
  33. # filerc (runlevel, service) returns /etc/init.d/service, if service is
  34. # running in $runlevel:
  35. filerc() {
  36.     local runlevel basename
  37.     runlevel=$1
  38.     basename=$2
  39.     while read LINE
  40.     do
  41.     case $LINE in
  42.         \#*|"") continue
  43.     esac
  44.  
  45.     set -- $LINE
  46.     SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
  47.     [ "$CMD" = "/etc/init.d/$basename" ] || continue
  48.  
  49.     if element "$runlevel" in "$START" || element "S" in "$START"
  50.     then
  51.         echo "/etc/init.d/$basename"
  52.         return 0
  53.     fi
  54.     done < /etc/runlevel.conf
  55.     echo ""
  56. }
  57.  
  58. checkpkgver () {
  59.     local status pkg
  60.     pkg=$1
  61.     status=$(dpkg -s $pkg 2>/dev/null | grep ^Status: | sed -e 's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
  62.     if [ -n "$status" ] && [ "$status" != "not-installed" ] && [ "$status" != "config-files" ]; then
  63.     echo $(dpkg -s $pkg 2>/dev/null | grep ^Version: | sed -e 's/^Version: *//');
  64.     fi
  65. }
  66.  
  67. if [ "$type" = "configure" ]
  68. then
  69.     # Add support for /etc/ld.so.conf.d
  70.     if [ -e /etc/ld.so.conf ]; then
  71.         [ -z "$(tail -n 1 /etc/ld.so.conf)" ] || echo >> /etc/ld.so.conf
  72.     else
  73.         touch /etc/ld.so.conf
  74.     fi
  75.     if ! grep -q '^include /etc/ld.so.conf.d/.*\.conf$' /etc/ld.so.conf ; then
  76.         echo 'include /etc/ld.so.conf.d/*.conf' >> /etc/ld.so.conf
  77.     fi
  78.  
  79.     # We don't use a registry anymore, remove the old file
  80.     rm -f /etc/ld.so.hwcappkgs
  81.  
  82.     # /etc/ld.so.nohwcap code: NOHWCAP
  83.     # Handle upgrades when libc-opt package has been installed.
  84.     # When a /etc/ld.so.nohwcap file exists, ld.so only use libraries
  85.     # from /lib, and ignore all optimised libraries. This file is
  86.     # inconditionaly created in the preinst script of libc.
  87.  
  88.     # Get the list of optimized packages for a given architecture
  89.     # Before removing a package from this list, make sure it appears
  90.     # in the Conflicts: line of libc.
  91.     case $(dpkg --print-architecture) in
  92.         alpha)
  93.             hwcappkgs="libc6-alphaev67"
  94.             ;;
  95.         i386)
  96.             hwcappkgs="libc6-i686 libc6-xen"
  97.             ;;
  98.         kfreebsd-i386)
  99.             hwcappkgs="libc0.1-i686"
  100.             ;;
  101.         sparc)
  102.             hwcappkgs="libc6-sparcv9 libc6-sparcv9b"
  103.             ;;
  104.     esac
  105.  
  106.     # We check the version between the current installed libc and
  107.     # all optimized packages (on architectures where such packages
  108.     # exists).
  109.     all_upgraded=yes
  110.     if [ -n "$hwcappkgs" ]; then
  111.         for pkg in $hwcappkgs ; do
  112.             ver=$(dpkg-query -l $pkg 2>/dev/null | sed -e '/^[a-z][a-z]\s/!d;/^.[nc]/d;' -e "s/^..\s\+$pkg\s\+//;s/\s.*//g")
  113.             if [ -n "$ver" ] && [ "$ver" != "2.11.3-4" ]; then
  114.                 all_upgraded=no
  115.             fi
  116.         done
  117.     fi
  118.  
  119.     # If the versions of all optimized packages are the same as the libc
  120.     # one, we could remove /etc/ld.so.nohwcap. Otherwise, it will be removed
  121.     # when all optimized packages are upgraded or removed.
  122.     if [ "$all_upgraded" = yes ] ; then
  123.         rm -f /etc/ld.so.nohwcap
  124.     fi
  125.  
  126.     # Load debconf module if available
  127.     if [ -f /usr/share/debconf/confmodule ] ; then
  128.     . /usr/share/debconf/confmodule
  129.     fi
  130.  
  131.     if [ -n "$preversion" ]; then
  132.     if [ ! -d /var/mail ] && [ ! -L /var/mail ]; then
  133.         ln -sf spool/mail /var/mail
  134.     fi
  135.     if dpkg --compare-versions "$preversion" lt 2.11-1; then
  136.         check="apache2.2-common apache apache-ssl apache-perl autofs at"
  137.         check="$check boa cucipop courier-authdaemon cron cups exim"
  138.         check="$check exim4-base dovecot-common cucipop incron lprng lpr"
  139.         check="$check lpr-ppd mysql-server nis openbsd-inetd"
  140.         check="$check openldapd proftpd postfix postfix-tls rsync samba"
  141.         check="$check sasl2-bin slapd smail sendmail snmpd ssh"
  142.         check="$check spamassassin vsftpd wu-ftpd wu-ftpd-academ wwwoffle"
  143.         check="$check webmin dropbear gdm"
  144.         # NSS services check: NSS_CHECK
  145.         echo -n "Checking for services that may need to be restarted..."
  146.         # Only get the ones that are installed, and configured
  147.         check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
  148.         # some init scripts don't match the package names
  149.         check=$(echo $check | \
  150.                 sed -e's/\bapache2.2-common\b/apache2/g' \
  151.                     -e's/\bat\b/atd/g' \
  152.                     -e's/\bdovecot-common\b/dovecot/g' \
  153.                     -e's/\bexim4-base\b/exim4/g' \
  154.                     -e's/\blpr\b/lpd/g' \
  155.                     -e's/\blpr-ppd\b/lpd-ppd/g' \
  156.                     -e's/\bmysql-server\b/mysql/g' \
  157.                     -e's/\bsasl2-bin\b/saslauthd/g' \
  158.         )
  159.         echo
  160.         echo "Checking init scripts..."
  161.         rl=$(runlevel | sed 's/.*\ //')
  162.         for service in $check; do
  163.             if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  164.                 invoke-rc.d ${service} status >/dev/null 2>/dev/null && status=0 || status=$?
  165.                 if [ "$status" = "0" ] || [ "$status" = "2" ] ; then
  166.                     services="$service $services"
  167.                 elif [ "$status" = "100" ] ; then
  168.                     echo "WARNING: init script for $service not found."
  169.                 fi
  170.             else
  171.                 if [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  172.                     idl=$(filerc $rl $service)
  173.                 else
  174.                     idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
  175.                 fi
  176.                 if [ -n "$idl" ] && [ -x $idl ]; then
  177.                     services="$service $services"
  178.                 fi
  179.             fi
  180.         done
  181.         if [ -n "$services" ]; then
  182.  
  183.             if [ -f /usr/share/debconf/confmodule ] ; then
  184.             db_version 2.0
  185.             db_reset glibc/restart-services
  186.             db_set glibc/restart-services "$services"
  187.             db_input critical glibc/restart-services || true
  188.             db_go || true
  189.             db_get glibc/restart-services
  190.             if [ "x$RET" != "x" ]
  191.             then
  192.                 services="$RET"
  193.             else
  194.                 services=""
  195.             fi
  196.         else
  197.             echo
  198.             echo "Name Service Switch update in the C Library: post-installation question."
  199.             echo
  200.             echo "Running services and programs that are using NSS need to be restarted,"
  201.             echo "otherwise they might not be able to do lookup or authentication any more"
  202.             echo "(for services such as ssh, this can affect your ability to login)."
  203.             echo "Note: restarting sshd/telnetd should not affect any existing connections."
  204.             echo
  205.             echo "The services detected are: "
  206.             echo "        $services"
  207.             echo
  208.             echo "If other services have begun to fail mysteriously after this upgrade, it is"
  209.             echo "probably necessary to restart them too.  We recommend that you reboot your"
  210.             echo "machine after the upgrade to avoid NSS-related troubles."
  211.             echo
  212.             frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  213.             if [ "$frontend" = noninteractive ]; then
  214.                 echo "Non-interactive mode, restarting services"
  215.                 answer=yes
  216.             else
  217.                 echo -n "Do you wish to restart services? [Y/n] "
  218.                 read answer
  219.                 case $answer in
  220.                 N*|n*) services="" ;;
  221.                 *) ;;
  222.                 esac
  223.             fi
  224.         fi
  225.         echo
  226.         if [ "$services" != "" ]; then
  227.             echo "Restarting services possibly affected by the upgrade:"
  228.             failed=""
  229.             for service in $services; do
  230.                 if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
  231.                 idl="invoke-rc.d ${service}"
  232.             elif [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  233.                 idl=$(filerc $rl $service)
  234.             else
  235.                 idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
  236.             fi
  237.             case "$service" in
  238.                 gdm)
  239.                 echo -n "  $service: reloading..."
  240.                 if $idl reload > /dev/null 2>&1; then
  241.                     echo "done."
  242.                 else
  243.                     echo "FAILED! ($?)"
  244.                     failed="$service $failed"
  245.                 fi
  246.                 ;;
  247.                 *)
  248.                 echo -n "  $service: restarting..."
  249.                 if $idl restart > /dev/null 2>&1; then
  250.                     echo "done."
  251.                 else
  252.                     echo "FAILED! ($?)"
  253.                     failed="$service $failed"
  254.                 fi
  255.                 ;;
  256.             esac
  257.             done
  258.             echo
  259.             if [ -n "$failed" ]; then
  260.                 if [ -f /usr/share/debconf/confmodule ] ; then
  261.                     db_fset glibc/restart-failed seen false
  262.                 db_subst glibc/restart-failed services "$failed"
  263.                 db_input critical glibc/restart-failed || true
  264.                 db_go || true
  265.             else
  266.                 echo "The following services failed to start: $failed"
  267.                 echo
  268.                 echo "You will need to start these manually by running \`/etc/init.d/<service> start'"
  269.                 echo "If the service still fails to start, you may need to file a bug on"
  270.                 echo "$(package_name) or the service involved."
  271.                 frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  272.                 if [ "$frontend" != noninteractive ]; then
  273.                     echo
  274.                     echo -n "Press ENTER to continue: "
  275.                     read foo
  276.                 fi
  277.             fi
  278.             else
  279.             echo "Services restarted successfully."
  280.                     fi
  281.         fi
  282.                 # Shut down the frontend, to make sure none of the
  283.         # restarted services keep a connection open to it
  284.             if [ -f /usr/share/debconf/confmodule ] ; then
  285.             db_stop
  286.         fi
  287.         else
  288.         echo "Nothing to restart."
  289.         fi
  290.     fi # end upgrading and $preversion lt 2.11-1
  291.     fi # Upgrading
  292.  
  293.     # Restart init. If it fails, there is nothing we can do, so 
  294.     #┬ájust ignore the error
  295.     telinit u 2> /dev/null || true ; sleep 1
  296. fi
  297.  
  298. # Automatically added by dh_makeshlibs
  299. if [ "$1" = "configure" ]; then
  300.     ldconfig
  301. fi
  302. # End automatically added section
  303.  
  304.  
  305. exit 0
  306.